package com.example.smart_campus.controller;


import com.example.smart_campus.common.Res;
import com.example.smart_campus.pojo.dto.grades.GradesTable;
import com.example.smart_campus.pojo.dto.grades.GradesItem;
import com.example.smart_campus.service.GradesService;
import jakarta.validation.Valid;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 成绩表，存储学生的成绩信息 前端控制器
 * </p>
 *
 * @author liyv
 * @since 2024-10-19
 */
@RestController
@RequestMapping("/grades")
public class GradesController {
    @Autowired
    GradesService gradesService ;

    /**
     * 查询课程所有成绩
     * @return 学生课程成绩list
     */
    @GetMapping("/gets/{cid}")
    public Res<List<GradesItem>> getsAll(@PathVariable String cid) {
        return gradesService.getAllGradesByCid(cid) ;
    }



    /**
     * 批量导入
     * @param tableList 课程成绩数据
     * @return res
     */
    @PostMapping("/import")
    public Res importByEList(@RequestBody @Valid List<GradesTable> tableList){
        return gradesService.importByEList(tableList) ;
    }

}

